﻿using Autofac;
using project.B12.application.Ioc;
using project.B12.ViewModels;
using System;
using System.ComponentModel;
using System.Windows;

namespace project.B12.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = ViewModelLocator.MainWindowViewModel;
            ViewModelLocator.MainWindowViewModel.CreateView();//初始化视图创建登录界面
            ViewModelLocator.MainWindowViewModel.ChangeToLoginView();//首次切换为登录界面
        }

        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            // TODO 弹框是否关闭程序
        }

        private void MainWindow_OnClosed(object sender, EventArgs e)
        {
            //TODO 程序关闭
            Environment.Exit(0);
        }

        /// <summary>
        /// 居中显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            this.Left = (System.Windows.SystemParameters.WorkArea.Width - this.ActualWidth) / 2;
            this.Top = (System.Windows.SystemParameters.WorkArea.Height - this.ActualHeight) / 2;
        }
    }
}
